#include<bits/stdc++.h>
#define int long long
 
using namespace std;

int a[3] = {6, 2, 3};

signed main() {
	int n;
	cin >> n;
	string t = ""; 
	while(n > 0) {
		cout << n % 3 << endl;
		t = (char)(a[n % 3] + '0') + t;
		n --;
		n /= 3;
	}
	cout << t << endl;
	return 0;
}

